package com.ssy.lingxi.platform.manage.controller;

import com.ssy.lingxi.common.response.Wrapper;
import com.ssy.lingxi.platform.manage.api.model.vo.site.SiteSelectVO;
import com.ssy.lingxi.platform.manage.api.model.vo.site.SiteVO;
import com.ssy.lingxi.platform.manage.entity.base.Site;
import com.ssy.lingxi.platform.manage.service.ISiteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @menu 站点
 * @author fhj
 * @version 2.0.0
 * @date 2020/9/17
 */
@Api(tags = "站点")
@RestController
@RequestMapping("/manage/paas/site")
public class SiteController {

    @Resource
    private ISiteService siteService;

    /**
     * 判断站点是否开启SAAS多租户
     *
     * @param siteId 站点id
     * @return 操作结果为boolean值
     */
    @GetMapping("/enableMultiTenancy")
    public Wrapper<Boolean> enableMultiTenancy(@RequestParam("siteId") Long siteId) {
        return siteService.enableMultiTenancy(siteId);
    }

    @ApiOperation(value = "查询所有站点")
    @GetMapping("/all")
    public Wrapper<List<Site>> siteAll() {
        return siteService.siteAll();
    }

    @ApiOperation(value = "查询站点详情")
    @GetMapping("/details")
    public Wrapper<SiteVO> details(@RequestParam(value = "id") Long id) {
        return siteService.details(id);
    }

    @ApiOperation(value = "根据url查询站点详情")
    @GetMapping("/by/url/details")
    public Wrapper<SiteVO> queryByUrlDetails(@RequestParam(value = "url") String url) {
        return siteService.queryByUrlDetails(url);
    }

    @ApiOperation(value = "获取站点下拉框")
    @GetMapping("/findSiteSelect")
    public Wrapper<List<SiteSelectVO>> findSiteSelect() {
        return siteService.findSiteSelect();
    }
}
